#ifndef _FILEUTILS_H
#define _FILEUTILS_H

#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>

#include "fileheader.h"
#include "CentralDirectory.h"

typedef unsigned long ULONG;

class FileDataExtractor
{
public:

    FileHeader* create_fheader(const char* file);

    CentralDirectory* create_cdirectory(FileHeader* header);

private:

    tm* getLastModifiedTime(const char *filepath);

    unsigned short calculate_modified_time(tm* time);

    unsigned short calculate_modified_date(tm* time);

    void makeLittleIndian(unsigned short& codedValue);

    int check(unsigned char* buffer, long bufsize);
    
    long FileSize(FILE *input);
    
    void InitCrcTable();
    
    ULONG reflect(ULONG ref, char ch);
    
    ULONG Get_CRC(unsigned char* buffer, ULONG bufsize);
};

#endif //_FILEUTILS_H